package com.example.springboot.common.service.impl;

import com.example.springboot.common.entity.CommonUser;
import com.example.springboot.common.mapper.CommonUserMapper;
import com.example.springboot.common.request.BaseRequest;
import com.example.springboot.common.request.LoginRequest;
import com.example.springboot.common.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户管理服务实现类
 */
@Service
@Transactional
public class UserServiceImpl implements IUserService {

    @Autowired
    private CommonUserMapper commonUserMapper;

    @Override
    public List<CommonUser> list() {
        return commonUserMapper.list();
    }

    @Override
    public List<CommonUser> listByCondition(BaseRequest baseRequest) {
        return commonUserMapper.listByCondition(baseRequest);
    }

    @Override
    public void save(CommonUser commonUser) {
        commonUserMapper.save(commonUser);
    }

    @Override
    public CommonUser getById(Integer id) {
        return commonUserMapper.getById(id);
    }

    @Override
    public void updateById(CommonUser commonUser) {
        commonUserMapper.updateById(commonUser);
    }

    @Override
    public void deleteById(Integer id) {
        commonUserMapper.deleteById(id);
    }

    @Override
    public CommonUser getByUsername(String username) {
        return commonUserMapper.getByUsername(username);
    }
    
    @Override
    public CommonUser getByUsernameAndPassword(LoginRequest loginRequest) {
        return commonUserMapper.getByUsernameAndPassword(loginRequest);
    }
}